<template>
    <div>
      <myhead ></myhead>

      <div class="bkimg">
        <img :src="obj.avatar" alt="">
        <button>蓝光</button>
      </div>

     <div class="swiper">
        <div class="fun">
        <span :class="{salmon:salmon === 1}" @click="clickChat">聊天</span>
        <span :class="{salmon:salmon === 2}" @click="clickVerse">主播</span>
        <span class="guanzhu">+关注</span>
      </div>

      <div v-if="salmon == 1">
        这里是聊天内容
      </div>

       <div v-if="salmon == 2">
          <p>{{obj.nickname}}</p>
          <p>{{obj.roomName}}</p>
      </div>

     </div>

<h5>相关直播</h5>
            <ul>
               <li v-for="(item,i) in anchor" :key="i" @click="getAnchor(item)" >
                   <img :src="item.avatar" alt="">
                   <p>{{item.roomName}}</p>

                   <span>{{item.hn}}</span>
                   <i>{{item.nickname}}</i>
               </li>
           </ul>



    </div>
</template>

<script>
import myhead from '@/components/myHead'
import {getRecommend} from '../utils/api'
export default {
    name: 'About',
    data() {
        return {
          obj:{},
          salmon:1,
          anchor:[]
        };
    },
    created() {
      this.obj = this.$route.query.item


      getRecommend().then(res => {
        console.log(res.data);
        this.anchor = res.data
      })
    },
    methods: {
      // 点击聊天
      clickChat() {
        this.salmon = 1
      },
      // 点击主播
      clickVerse() {
        this.salmon = 2
      },
       getAnchor(item) {
         console.log(item);
         
            this.$router.push({
                path:'/About',
                query:{
                    item
                }
            })
            
        }
    },
    //组件挂载
    components: {
      myhead
    },
    //计算属性
    computed: {},
    //过滤器
    filters: {},
};
</script>

<style lang="scss" scoped>
.bkimg{
  width: 100%;
  height: 200px;
  border: deeppink 1px solid;
  box-sizing: border-box;
  position: relative;
  img{
    width: 100%;
    height: 100%;
  }
  button{
    position: absolute;
    right: 15px;
    top:15px;
    border-radius: 20px;
    padding:4px 8px;
    border: #fff 1px solid;
    background-color: rgba($color: #000000, $alpha: 0);
    color: #fff;
    outline: none;
  }
}

.swiper{
  width: 100%;
  position: relative;

  .fun{
  width: 80%;
  height: 50px;
  // background-color: rgb(114, 105, 101);
  display: flex;
  justify-content: space-around;
  align-items: center;
  .salmon{
    color: salmon;
    border-bottom: salmon 2px solid;
  }
  .guanzhu{
    background-color: salmon;
    position: absolute;
    right: 0;
    height: 74%;
    line-height: 46px;
    width: 22%;
    text-align: center;
    color: #fff;
  }
}
}
h5{
  margin-top: 100px;
}
ul{
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        li{
            width: 48%;
            height: 140px;
            position: relative;
            font-size: 12px;
            img{
                width: 100%;
                height: 80%;
                border-radius: 4px;

            }
            p{
                line-height: 28px;
            }
            span{
                position: absolute;
                right: 0;
                top: 0;
                display: block;
                background-color: #76767F;
                color: #fff;
                line-height: 20px;
                padding: 0 4px;
            }
            i{
                position: absolute;
                left: 0;
                bottom: 28px;
                display: block;
                color: #fff;
                line-height: 20px;
                padding: 0 4px;
            }
        }
    }
</style>
